package com.happyclub.pojo;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @Auther: 魏泉琦
 * @Date: 2019/4/6 14:09
 * @Description: 相册表
 */
@Entity
@Table(name = "TB_PHOTO_ALBUM", schema = "SCOTT")
@EntityListeners(AuditingEntityListener.class)
public class TbPhotoAlbum implements Serializable {
    private String id;
    private Date updateTime;
    private Date createTime;
    private String albumName;
    private String albumDefaultPicture;

    private List<TbPhotoLibrary> photoLibraries;     //多个相片

    @Transient
    public List<TbPhotoLibrary> getPhotoLibraries() {
        return photoLibraries;
    }

    public void setPhotoLibraries(List<TbPhotoLibrary> photoLibraries) {
        this.photoLibraries = photoLibraries;
    }

    @Id
    @Column(name = "ID")
    @GenericGenerator(name="idGenerator", strategy="uuid") //这个是hibernate的注解/生成32位UUID
    @GeneratedValue(generator="idGenerator")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "UPDATE_TIME")
    @LastModifiedDate
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    @CreatedDate
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "ALBUM_NAME")
    public String getAlbumName() {
        return albumName;
    }

    public void setAlbumName(String albumName) {
        this.albumName = albumName;
    }

    @Basic
    @Column(name = "ALBUM_DEFAULT_PICTURE")
    public String getAlbumDefaultPicture() {
        return albumDefaultPicture;
    }

    public void setAlbumDefaultPicture(String albumDefaultPicture) {
        this.albumDefaultPicture = albumDefaultPicture;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbPhotoAlbum that = (TbPhotoAlbum) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(updateTime, that.updateTime) &&
                Objects.equals(createTime, that.createTime) &&
                Objects.equals(albumName, that.albumName) &&
                Objects.equals(albumDefaultPicture, that.albumDefaultPicture);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, updateTime, createTime, albumName, albumDefaultPicture);
    }
}
